//
//  BaseViewController.m
//  NoneCar
//
//  Created by DongSen on 2018/7/10.
//  Copyright © 2018年 董森森. All rights reserved.
//
#import "TipsView.h"
#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.
}
-(void)setTitle:(NSString *)title{
    self.titleLabel.text = title;
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

}
- (UILabel *)titleLabel{
    if (!_titleLabel){
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = Font(16);
        _titleLabel.frame = CGRectMake(0, 0, kSCREEN_W/2, kNAVIGATIONTITLEHEIGHT);
        _titleLabel.textAlignment=NSTextAlignmentCenter;
        _titleLabel.textColor = [UIColor blackColor];
        self.navigationItem.titleView = _titleLabel;
    }
    return _titleLabel;
}
-(BlackView *)blackView{
    if (!_blackView) {
        _blackView =[BlackView loadView];
    }
    return _blackView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)showLoading{
    dispatch_main_async_safe(^{
        [TipsView showloadinginView:self.view];
    });
}

- (void)hidloading{
    dispatch_main_async_safe(^{
        [TipsView hidView];
    });
}
- (void)showNetError{
    [self showMessage:@"网络连接异常请您稍后再试"];
}
- (void)showMessage:(NSString *)message{
    [TipsView showMessage:message inView:self.view];
}
- (void)pop {
    if (self.navigationController == nil) return ;
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)popToRootVc {
    if (self.navigationController == nil) return ;
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)popToVc:(UIViewController *)vc {
    if ([vc isKindOfClass:[UIViewController class]] == NO) return ;
    if (self.navigationController == nil) return ;
    [self.navigationController popToViewController:vc animated:YES];
}

- (void)dismiss {
    [self dismissViewControllerAnimated:YES completion:nil];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
